﻿
using System;
using PsqlDotnet.Enums;
namespace PsqlDotnet.Model.Schema
{
    public class Column
    {
        public string Parent { get; internal set; }
        public string Name { get; private set; }
        public DbDataTypeEnum DataType { get; private set; }
        public int Precision { get; private set; }
        public int FieldSize { get; private set; }
        public bool IsNullable { get; private set; }

        public Column(string name, ColumnDataInfo info)
        {
            if (String.IsNullOrWhiteSpace(name))
                throw new ArgumentException("Illegal null or empty column name");

            Name = name;
            DataType = info.DataType;
            FieldSize = info.FieldSize;
            Precision = info.Precision;
            IsNullable = info.IsNullable;
        }
    }
}
